package data

import (
	"context"
	"digitalhuman/models"
	"github.com/go-kratos/kratos/v2/log"
)

type StoryboardSectionData struct {
	Data *Data
	log  *log.Helper
}

func (u StoryboardSectionData) Create(ctx context.Context, s *models.StoryboardSection) (*models.StoryboardSection, error) {
	u.Data.Db.Create(s)

	return s, nil
}

func (u StoryboardSectionData) Update(ctx context.Context, s *models.StoryboardSection) (*models.StoryboardSection, error) {
	u.Data.Db.Updates(s)

	return s, nil
}

func (u StoryboardSectionData) UpdateStatus(ctx context.Context, id int, status int) (bool, error) {
	u.Data.Db.Model(&models.StoryboardSection{}).Where("id = ?", id).Update("status", status)

	return true, nil
}

func (u StoryboardSectionData) FindByID(ctx context.Context, i int64) (*models.StoryboardSection, error) {
	var user *models.StoryboardSection
	u.Data.Db.Where("id = ?", i).First(&user)
	if user == nil {

	}
	return user, nil
}

func NewStoryboardSectionData(data *Data, logger log.Logger) *StoryboardSectionData {
	return &StoryboardSectionData{
		Data: data,
		log:  log.NewHelper(logger),
	}
}
